<?php
/*
 * 后台登陆控制器
 */
class LoginController extends Controller{
    //动作方法
    public function index(){
    	if(IS_POST){
    		$Model = K('user');
			if(!$userInfo = $Model->login()){
				$this->error($Model->error);
			}
			//写入session
			session('aid',$userInfo['uid']);
			session('adminname',$userInfo['username']);
			$this->success('登录成功',U('Admin/Index/'));
    	}
        //显示视图
        $this->display();
    }
	//实例化验证码
	public function code(){
		$code = new Code();
		$code->show();
	}
	//注销登录
	public function loginOut(){
		session(null);
		$this->success('注销成功',__ROOT__);
	}
}
